<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>旅行信息</title>
	<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<!--标准mui.css-->
	<link rel="stylesheet" href="../css/mui.min.css">
	<link rel="stylesheet" href="../css/mui.picker.css" />
	<link rel="stylesheet" type="text/css" href="../css/mui.picker.min.css" />
	<link rel="stylesheet" href="../css/mui.poppicker.css" />
	<link rel="stylesheet" href="../css/common.css" />
	<style>
		.mui-input-group .mui-input-row {
			height: 55px;
		}
		.mui-input-row label {
			padding: 0 15px;
			line-height: 55px;
		}
		.mui-input-row label~input {
			margin-top: 7px;
		}
		.mui-input-row label~input::-webkit-input-placeholder {
			color: #999;
		}
		.mui-input-row label,label~input {
			font-family: 'PingFangSC-Regular';
		    font-size: 14px;
		    color: #666666;
		}
		.down-select {
			float: right;
			width: 65%;
			font-family: 'PingFangSC-Regular';
		    font-size: 14px;
		    color: #666666;
		    line-height: 55px;
		}
		.down-select label {
			width: 80%;
			padding: 0;
			color: #333;
		}
		.down-select img {
			float: right;
			margin-top: 10px;
			margin-right: 18px;
			width: 28px;
		    height: 28px;
		    vertical-align: middle;
		}
		.mui-input-row .label-title {
			background: #FAFAFA;
			font-size: 14px;
			color: #333333;
		}
		.ladder {
			display: none;
			margin-left: 10px;
		}
		.line-font {
			padding: 5px 0;
			padding-left: 14px;
			background: #FAFAFA;
			font-size: 14px;
			color: #666;
		}
	</style>
</head>
<body>
	<header class="mui-bar mui-bar-nav">
		<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		<h1 class="mui-title">旅行信息</h1>
	</header>
	<div class="mui-content">
		<form class="mui-input-group" style="padding-bottom: 55px;">
			<input type="hidden" id="travelInfoId" />
			<div class="mui-input-row">
				<label>访问目的</label>
				<div id="showObjective" class="down-select">
					<label id="objectiveResult">请选择</label>
					<img src="../img/detail/down_color_icon.png" />
				</div>
			</div>
			<div class="mui-input-row">
				<label>访问经费预算</label>
				<input type="number" id="budget" placeholder="请输入数字，按人民币计" value="" >
			</div>
			<div class="mui-input-row">
				<label>预计入境日期</label>
				<div data-options='{"type":"date"}' class="down-select showDatePicker">
					<label id="entryTime" class="dateResult"></label>
					<img src="../img/detail/down_color_icon.png" />
				</div>
			</div>
			<div class="mui-input-row">
				<label>预计离境日期</label>
				<div data-options='{"type":"date"}' class="down-select showDatePicker">
					<label id="departureTime" class="dateResult"></label>
					<img src="../img/detail/down_color_icon.png" />
				</div>
			</div>
			<div class="mui-input-row">
				<label style="margin-top: 5px;line-height: 22px;">五年内是否访问过韩国</label>
				<div id="showVisitKorea" class="down-select">
					<label id="visitKoreaResult"></label>
					<input type="hidden" id="isTo" value="0" />
					<img src="../img/detail/down_color_icon.png" />
				</div>
			</div>
			<div id="isVisitKores" class="ladder">
				<div class="mui-input-row">
					<label>访问次数</label>
					<input type="number" id="visitNum" placeholder="请输入数字" value="" >
				</div>
				<div class="mui-input-row">
					<label>最近访韩目的</label>
					<div id="showLatelyObjective" class="down-select">
						<label id="latelyObjectiveResult">请选择</label>
						<img src="../img/detail/down_color_icon.png" />
					</div>
				</div>
			</div>
			<div class="mui-input-row">
				<label style="margin-top: 5px;line-height: 22px;">最近五年是否访问过其他国家</label>
				<div id="showVisitOther" class="down-select">
					<label id="visitOtherResult"></label>
					<input type="hidden" id="isToOtherCountry" value="0" />
					<img src="../img/detail/down_color_icon.png" />
				</div>
			</div>
			<div id="accessRecord" style="display: none;">
				<div style="height: 70px;" class="mui-input-row">
					<label>访问记录</label>
					<button id="addCard" style="float: right;margin: 12px 15px 0 0;color: #FF4747;" type="button" class="mui-btn mui-btn-link">+新增</button>
					<input style="margin-top: -22px;margin-left: 14px;width: 100%;" type="text" placeholder="注：最多添加3条访问记录，优先填写欧美等发达国家" readonly="readonly"></input>
				</div>
				<div id="accessRecordCard">
					<div class="mui-card" style="padding-bottom: 10px;">
						<ul class="mui-table-view">
							<input type="hidden" name="travelInfoCountryId" value="" />
							<div class="mui-input-row" style="background: #FAFAFA;">
								<label class="label-title">访问记录1</label>
							</div>
							<div class="mui-input-row">
								<label>国家名称</label>
								<input type="text" name="countryName" placeholder="" value="" >
							</div>
							<div class="mui-input-row">
								<label>访问目的</label>
								<div class="down-select show-objective">
									<label class="objective_result">请选择</label>
									<img src="../img/detail/down_color_icon.png" />
								</div>
							</div>
							<div class="mui-input-row">
								<label>入境日期</label>
								<div data-options='{"type":"date"}' class="down-select showDatePicker">
									<label class="dateResult entryTime"></label>
									<img src="../img/detail/down_color_icon.png" />
								</div>
							</div>
							<div class="mui-input-row">
								<label>离境日期</label>
								<div data-options='{"type":"date"}' class="down-select showDatePicker">
									<label class="dateResult departureTime"></label>
									<img src="../img/detail/down_color_icon.png" />
								</div>
							</div>
						</ul>	
					</div>	
				</div>
			</div>
			<div class="mui-input-row">
				<label>是否有家属同行</label>
				<div id="showFamilyColleague" class="down-select">
					<label id="familyColleagueResult"></label>
					<input type="hidden" id="isFamily" value="0" />
					<img src="../img/detail/down_color_icon.png" />
				</div>
			</div>
			<div id="familyColleague" style="display: none;">
				<div style="height: 70px;" class="mui-input-row">
					<label>同行家属信息</label>
					<button id="addFamilyCard" style="float: right;margin: 12px 15px 0 0;color: #FF4747;" type="button" class="mui-btn mui-btn-link">+新增</button>
					<input style="margin-top: -22px;margin-left: 14px;width: 100%;" type="text" placeholder="注：仅需填写同行父母、配偶、子女或亲生兄弟姐妹" readonly="readonly"></input>
				</div>
				<div id="familyColleagueCard">
					<div class="mui-card" style="padding-bottom: 10px;">
						<ul class="mui-table-view">
							<input type="hidden" name="travelInfoFamilyId" value="" />
							<div class="mui-input-row" style="background: #FAFAFA;">
								<label class="label-title">家属信息1</label>
							</div>
							<div class="mui-input-row">
								<label>姓名（拼音）</label>
								<input type="text" name="name" placeholder="" value="" >
							</div>
							<div class="mui-input-row">
								<label>出生年月</label>
								<div data-options='{"type":"date","beginYear":1900,"endYear":2020}' class="down-select showDatePicker">
									<label class="dateResult"></label>
									<img src="../img/detail/down_color_icon.png" />
								</div>
							</div>
							<div class="mui-input-row">
								<label>国籍</label>
								<input type="text" name="nationality" placeholder="" value="中国" />
							</div>
							<div class="mui-input-row">
								<label>关系</label>
								<div class="down-select show-relation">
									<label class="relation_result">请选择</label>
									<img src="../img/detail/down_color_icon.png" />
								</div>
							</div>
						</ul>	
					</div>	
				</div>	
			</div>
			<div class="line-font">紧急联系人信息</div>
			<div class="mui-input-row">
				<label>姓名（拼音）</label>
				<input type="text" id="emergencyPersonName" placeholder="" value="" >
			</div>
			<div class="mui-input-row">
				<label>所在国家</label>
				<input type="text" id="inCountry" placeholder="" value="中国" >
			</div>
			<div class="mui-input-row">
				<label>手机号码</label>
				<input type="number" id="emergencyPersonPhone" placeholder="" value="" >
			</div>
			<div class="mui-input-row">
				<label>与申请人关系</label>
				<input type="text" id="applyCustomerRelationship" placeholder="" value="" >
			</div>
		</form>	
		<div class="transaction-container"><button type="button">保存</button></div>
	</div>	
	<script type="text/javascript" src="../js/thirdparty/jquery-3.3.1.js" ></script>
	<script type="text/javascript" src="../js/thirdparty/mui.min.js" ></script>
	<script type="text/javascript" src="../js/thirdparty/mui.picker.js"></script>
	<script type="text/javascript" src="../js/thirdparty/mui.picker.min.js"></script>
	<script type="text/javascript" src="../js/thirdparty/mui.poppicker.js"></script>
	<script type="text/javascript" src="../js/utils/regular.js" ></script>
	<script type="text/javascript" src="../js/thirdparty/spin.min.js" ></script>
	<script type="text/javascript" src="../js/utils/boot.js" ></script>
	<script>
		var customerId = base.getParameter("customerId");
		var applyCustomerId = base.getParameter("applyCustomerId");
		var countryId = base.getParameter("countryId");
		(function($, doc) {
			$.init();
			initTravelJapan();
			//访问目的
			var objectivePicker = new $.PopPicker();
			objectivePicker.setData([{
				value: '1',
				text: '旅游'
			}, {
				value: '2',
				text: '商务'
			}, {
				value: '3',
				text: '探亲访友'
			}, {
				value: '4',
				text: '留学'
			}]);
			var showObjectiveButton = doc.getElementById('showObjective');
			var objectiveResult = doc.getElementById('objectiveResult');
			showObjectiveButton.addEventListener('tap', function(event) {
				objectivePicker.show(function(items) {
					objectiveResult.innerText = _getParam(items[0], "text");
				});
			}, false);
			//最近访问韩国目的
			var showLatelyObjectiveButton = doc.getElementById('showLatelyObjective');
			var latelyObjectiveResult = doc.getElementById('latelyObjectiveResult');
			showLatelyObjectiveButton.addEventListener('tap', function(event) {
				objectivePicker.show(function(items) {
					latelyObjectiveResult.innerText = _getParam(items[0], "text");
				});
			}, false);
			//是否
			var whetherPicker = new $.PopPicker();
			whetherPicker.setData([{
				value: '1',
				text: '是'
			}, {
				value: '2',
				text: '否'
			}]);
			//时间选择器
			$(".mui-input-group").on('tap', '.showDatePicker',function(e) {
				var _self = this;
				if(_self.picker) {
					_self.picker.show(function (rs) {
						jQuery(_self).find(".dateResult").html(rs.text);
						_self.picker.dispose();
						_self.picker = null;
					});
				} else {
					var optionsJson = this.getAttribute('data-options') || '{}';
					var options = JSON.parse(optionsJson);
					_self.picker = new $.DtPicker(options);
					_self.picker.show(function(rs) {
						jQuery(_self).find(".dateResult").html(rs.text);
						_self.picker.dispose();
						_self.picker = null;
					});
				}
			}, false);
			//访问目的
			$(".mui-input-group").on('tap', '.show-objective', function(e){
				var _self = this;
				objectivePicker.show(function(items) {
					jQuery(_self).find(".objective_result").html(_getParam(items[0], "text"));
				});
			},false);
			//是否访问过韩国
			var showVisitKoreaButton = doc.getElementById('showVisitKorea');
			var visitKoreaResult = doc.getElementById('visitKoreaResult');
			showVisitKoreaButton.addEventListener('tap', function(event) {
				whetherPicker.show(function(items) {
					visitKoreaResult.innerText = _getParam(items[0], "text");
					if (_getParam(items[0], "value") == 1) {
						jQuery("#isVisitKores").show();
						jQuery("#isTo").val(1);
					}else if (_getParam(items[0], "value") == 2) {
						jQuery("#isVisitKores").hide();
						jQuery("#isTo").val(0);
					}
				});
			}, false);
			//是否访问过其他国家
			var showVisitOtherButton = doc.getElementById('showVisitOther');
			var visitOtherResult = doc.getElementById('visitOtherResult');
			showVisitOtherButton.addEventListener('tap', function(event) {
				whetherPicker.show(function(items) {
					visitOtherResult.innerText = _getParam(items[0], "text");
					if (_getParam(items[0], "value") == 1) {
						jQuery("#accessRecord").show();
						jQuery("#isToOtherCountry").val(1);
					}else if (_getParam(items[0], "value") == 2) {
						jQuery("#accessRecord").hide();
						jQuery("#isToOtherCountry").val(0);
					}
				});
			}, false);
			//是否有家属同行
			var showFamilyColleagueButton = doc.getElementById('showFamilyColleague');
			var familyColleagueResult = doc.getElementById('familyColleagueResult');
			showFamilyColleagueButton.addEventListener('tap', function(event) {
				whetherPicker.show(function(items) {
					familyColleagueResult.innerText = _getParam(items[0], "text");
					if (_getParam(items[0], "value") == 1) {
						jQuery("#familyColleague").show();
						jQuery("#isFamily").val(1);
					}else if (_getParam(items[0], "value") == 2) {
						jQuery("#familyColleague").hide();
						jQuery("#isFamily").val(0);
					}
				});
			}, false);
			//家属关系
			var relationPicker = new $.PopPicker();
			relationPicker.setData([{
				value: '1',
				text: '配偶'
			}, {
				value: '2',
				text: '子女'
			}, {
				value: '3',
				text: '父母'
			}, {
				value: '4',
				text: '兄弟'
			}, {
				value: '5',
				text: '姐妹'
			}]);
			$(".mui-input-group").on('tap', '.show-relation', function(e){
				var _self = this;
				relationPicker.show(function(items) {
					jQuery(_self).find(".relation_result").html(_getParam(items[0], "text"));
				});
			},false);
		})(mui, document);	
		//添加访问记录
		$("#addCard").on("tap",function(){
			$("#accessRecordCard").prepend(htmlCard("",1));
		});
		//删除访问记录
		$("#accessRecordCard").on('tap', '.delect-card', function(){
			var _self = this;
			$(_self).closest(".mui-card").remove();
			var cardLength = $("#accessRecordCard").find(".mui-card").length;
			$("#accessRecordCard .label-title").each(function(i, e){
				$(this).html("访问记录"+cardLength);
				cardLength --;
			});
			
		});
		function htmlCard(obj,i){
			var cardLength = 1;
			if (obj == "") {
				cardLength = $("#accessRecordCard").find(".mui-card").length + 1;
			}else{
				cardLength = i+1;
			}
			if (cardLength > 3) {
				return;
			}
			var html = '<div class="mui-card" style="padding-bottom: 10px;">'+
						'	<ul class="mui-table-view">'+
						'		<input type="hidden" name="travelInfoCountryId" value="'+(obj==""?"":obj.travelInfoCountryId)+'" />'+
						'		<div class="mui-input-row" style="background: #FAFAFA;">'+
						'			<label class="label-title">访问记录'+cardLength+'</label>';
					if (i > 0){	
				html +=	'			<button style="float: right;margin: 12px 15px 0 0;color: #999;" type="button" class="mui-btn mui-btn-link delect-card"><span style="vertical-align:top;" class="mui-icon mui-icon-trash"></span>删除</button>';
					}	
				html +=	'		</div>'+
						'		<div class="mui-input-row">'+
						'			<label>国家名称</label>'+
						'			<input type="text" name="countryName" placeholder="" value="'+(obj==""?"":obj.countryName)+'" >'+
						'		</div>'+
						'		<div class="mui-input-row">'+
						'			<label>访问目的</label>'+
						'			<div class="down-select show-objective">'+
						'				<label class="objective_result">'+(obj==""?"请选择":obj.visitPurpose)+'</label>'+
						'				<img src="../img/detail/down_color_icon.png" />'+
						'			</div>'+
						'		</div>'+
						'		<div class="mui-input-row">'+
						'			<label>入境日期</label>'+
						'			<div data-options=\'{"type":"date"}\' class="down-select showDatePicker">'+
						'				<label class="dateResult entryTime">'+(obj==""?"":obj.entryTime)+'</label>'+
						'				<img src="../img/detail/down_color_icon.png" />'+
						'			</div>'+
						'		</div>'+
						'		<div class="mui-input-row">'+
						'			<label>离境日期</label>'+
						'			<div data-options=\'{"type":"date"}\' class="down-select showDatePicker">'+
						'				<label class="dateResult departureTime">'+(obj==""?"":obj.departureTime)+'</label>'+
						'				<img src="../img/detail/down_color_icon.png" />'+
						'			</div>'+
						'		</div>'+
						'	</ul>'+	
						'</div>	';
			return html;			
		}
		//添加家属信息
		$("#addFamilyCard").on("tap",function(){
			$("#familyColleagueCard").prepend(htmlFamilyCard("",1));
		});
		//删除家属信息
		$("#familyColleagueCard").on('tap', '.delect-card', function(){
			var _self = this;
			$(_self).closest(".mui-card").remove();
			var cardLength = $("#familyColleagueCard").find(".mui-card").length;
			$("#familyColleagueCard .label-title").each(function(i, e){
				$(this).html("家属信息"+cardLength);
				cardLength --;
			});
			
		});
		function htmlFamilyCard(obj,i){
			var cardLength = 1;
			if (obj == "") {
				cardLength = $("#familyColleagueCard").find(".mui-card").length + 1;
			}else{
				cardLength = i+1;
			}
			var html = '<div class="mui-card" style="padding-bottom: 10px;">'+
						'	<ul class="mui-table-view">'+
						'		<input type="hidden" name="travelInfoFamilyId" value="'+(obj==""?"":obj.travelInfoFamilyId)+'" />'+
						'		<div class="mui-input-row" style="background: #FAFAFA;">'+
						'			<label class="label-title">家属信息'+cardLength+'</label>';
					if (i > 0){	
				html +=	'			<button style="float: right;margin: 12px 15px 0 0;color: #999;" type="button" class="mui-btn mui-btn-link delect-card"><span style="vertical-align:top;" class="mui-icon mui-icon-trash"></span>删除</button>';
					}
				html +=	'		</div>'+
						'		<div class="mui-input-row">'+
						'			<label>姓名（拼音）</label>'+
						'			<input type="text" name="name" placeholder="" value="'+(obj==""?"":obj.name)+'" >'+
						'		</div>'+
						'		<div class="mui-input-row">'+
						'			<label>出生年月</label>'+
						'			<div data-options=\'{"type":"date","beginYear":1900,"endYear":2020}\' class="down-select showDatePicker">'+
						'				<label class="dateResult">'+(obj==""?"":obj.birthday)+'</label>'+
						'				<img src="../img/detail/down_color_icon.png" />'+
						'			</div>'+
						'		</div>'+
						'		<div class="mui-input-row">'+
						'			<label>国籍</label>'+
						'			<input type="text" name="nationality" placeholder="" value="'+(obj==""?"中国":obj.nationality)+'" >'+
						'		</div>'+
						'		<div class="mui-input-row">'+
						'			<label>关系</label>'+
						'			<div class="down-select show-relation">'+
						'				<label class="relation_result">'+(obj==""?"请选择":obj.relationship)+'</label>'+
						'				<img src="../img/detail/down_color_icon.png" />'+
						'			</div>'+
						'		</div>'+
						'	</ul>'+	
						'</div>';
			return html;			
		}
		var _getParam = function(obj, param) {
			return obj[param] || '';
		};
		//获取旅行信息
		function initTravelJapan(){
			base.setWait('正在获取数据');
			let url = base.url.getTravelInfo;
			var params = {
				customerId: customerId,
				applyCustomerId: applyCustomerId,
				cuntryId: countryId
			}
			base.postData(url, params, getTravelInfoSuccess);
		}
		function getTravelInfoSuccess(data) {
			if (data.success) {
				if (data.extendData) {
					$("#objectiveResult").text(data.extendData.visitPurpose);
					$("#travelInfoId").val(data.extendData.travelInfoId);
					$("#budget").val(data.extendData.budget);
					$("#entryTime").text(data.extendData.entryTime);
					$("#departureTime").text(data.extendData.departureTime);
					if (data.extendData.isTo == 1) {
						$("#visitKoreaResult").text("是");
						$("#isTo").val(1);
						$("#isVisitKores").show();
						$("#visitNum").val(data.extendData.visitNum);
						$("#latelyObjectiveResult").text(data.extendData.lastVisitPurpose);
					}
					if (data.extendData.isTo == 0) {
						$("#visitKoreaResult").text("否");
					}
					if (data.extendData.isToOtherCountry == 1) {
						$("#isToOtherCountry").val(1);
						$("#visitOtherResult").text("是");
						$("#accessRecord").show();
						if (data.extendData.travelInfoCountryList.length>0) {
							$("#accessRecordCard").html("");
							for (var i=0;i<data.extendData.travelInfoCountryList.length;i++) {
								var html = htmlCard(data.extendData.travelInfoCountryList[i],i);
								$("#accessRecordCard").prepend(html);
							}
						}
					}
					if (data.extendData.isToOtherCountry == 0) {
						$("#visitOtherResult").text("否");
					}
					if (data.extendData.isFamily == 1) {
						$("#isFamily").val(1);
						$("#familyColleagueResult").text("是");
						$("#familyColleague").show();
						if (data.extendData.travelInfoFamilyList.length>0) {
							$("#familyColleagueCard").html("");
							for (var i=0;i<data.extendData.travelInfoFamilyList.length;i++) {
								var html = htmlFamilyCard(data.extendData.travelInfoFamilyList[i],i);
								$("#familyColleagueCard").prepend(html);
							}
						}
					}
					if (data.extendData.isFamily == 0) {
						$("#familyColleagueResult").text("否");
					}
					$("#emergencyPersonName").val(data.extendData.emergencyPersonName);
					$("#inCountry").val(data.extendData.inCountry);
					$("#emergencyPersonPhone").val(data.extendData.emergencyPersonPhone);
					$("#applyCustomerRelationship").val(data.extendData.applyCustomerRelationship);
				}
			}
		}
		//保存旅行信息
		$(".transaction-container").on('tap', 'button', function(){
			var objectiveResult = $("#objectiveResult").text();
			if (objectiveResult == "" || objectiveResult == "请选择") {
				mui.toast("请选择访问目的");
				return;
			}
			var budget = $("#budget").val();
			if (budget == '' || budget == 0) {
				mui.toast("请填写访问经费预算");
				return;
			}
			var entryTime = $("#entryTime").text();
			if (entryTime == "") {
				mui.toast("请填写预计入境日期");
				return;
			}
			var departureTime = $("#departureTime").text();
			if (departureTime == "") {
				mui.toast("请填写预计离境日期");
				return;
			}
			var visitKoreaResult = $("#visitKoreaResult").text();
			if (visitKoreaResult == "") {
				mui.toast("请选择五年内是否访问过韩国");
				return;
			}
			var visitNum = $("#visitNum").val();
			var latelyObjectiveResult = $("#latelyObjectiveResult").text();
			if (visitKoreaResult == "是") {
				if (visitNum == "" || visitNum == 0) {
					mui.toast("请填写访问次数");
					return;
				}
				if (latelyObjectiveResult == "" || latelyObjectiveResult == "请选择") {
					mui.toast("请选择最近访韩目的");
					return;
				}
			}
			var visitOtherResult = $("#visitOtherResult").text();
			if (visitOtherResult == "") {
				mui.toast("请选择最近五年是否访问过其他国家");
				return;
			}
			var isToOtherCountryParameter = new Array();
			var accessRecordFlag = false;
			if (visitOtherResult == "是") {
				$("#accessRecordCard").find(".mui-card").each(function(e){
					var travelInfoCountryId = $(this).find("input[name='travelInfoCountryId']").val();
					var countryName = $(this).find("input[name='countryName']").val();
					if (countryName == "") {
						mui.toast("请填写国家名称");
						accessRecordFlag = true;
						return false;
					}
					var visitPurpose = $(this).find(".objective_result").text();
					if (visitPurpose == "" || visitPurpose == "请选择") {
						mui.toast("请选择访问目的");
						accessRecordFlag = true;
						return false;
					}
					var entryTime = $(this).find(".entryTime").text();
					if (entryTime == "") {
						mui.toast("请填写入境日期");
						accessRecordFlag = true;
						return false;
					}
					var departureTime = $(this).find(".departureTime").text();
					if (departureTime == "") {
						mui.toast("请填写离境日期");
						accessRecordFlag = true;
						return false;
					}
					var accessRecord = {
						travelInfoCountryId:travelInfoCountryId,
						countryName:countryName,
						visitPurpose:visitPurpose,
						entryTime:entryTime,
						departureTime:departureTime
					}
					isToOtherCountryParameter.push(accessRecord);
				});
				if (accessRecordFlag) {
					return;
				}
				isToOtherCountryParameter = JSON.stringify(isToOtherCountryParameter);
			}
			var familyColleagueResult = $("#familyColleagueResult").text();
			if (familyColleagueResult == "") {
				mui.toast("请选择是否有家属同行");
				return;
			}
			var isFamilyParameter = new Array();
			var familyColleagueFlag = false;
			if (familyColleagueResult == "是") {
				$("#familyColleagueCard").find(".mui-card").each(function(e){
					var travelInfoFamilyId = $(this).find("input[name='travelInfoFamilyId']").val();
					var name = $(this).find("input[name='name']").val();
					if (name == "") {
						mui.toast("请填写姓名（拼音）");
						familyColleagueFlag = true;
						return;
					}
					var birthday = $(this).find(".dateResult").text();
					if (birthday == "") {
						mui.toast("请填写出生年月");
						familyColleagueFlag = true;
						return;
					}
					var nationality = $(this).find("input[name='nationality']").val();
					if (nationality == "") {
						mui.toast("请填写国籍");
						familyColleagueFlag = true;
						return;
					}
					var relationship = $(this).find(".relation_result").text();
					if (relationship == "" || relationship == "请选择") {
						mui.toast("请选择关系");
						familyColleagueFlag = true;
						return;
					}
					var familyColleague = {
						travelInfoFamilyId:travelInfoFamilyId,
						name:name,
						birthday:birthday,
						nationality:nationality,
						relationship:relationship
					}
					isFamilyParameter.push(familyColleague);
				});	
				if (familyColleagueFlag) {
					return;
				}
				isFamilyParameter = JSON.stringify(isFamilyParameter);
			}
			var emergencyPersonName = $("#emergencyPersonName").val();
			if (emergencyPersonName == "") {
				mui.toast("请填写紧急联系人姓名");
				return;
			}
			var inCountry = $("#inCountry").val();
			if (inCountry == "") {
				mui.toast("请填写紧急联系人所在国家");
				return;
			}
			var emergencyPersonPhone = $("#emergencyPersonPhone").val();
			if (emergencyPersonPhone == "") {
				mui.toast("请填写紧急联系人号码");
				return;
			}
			var applyCustomerRelationship = $("#applyCustomerRelationship").val();
			if (applyCustomerRelationship == "") {
				mui.toast("请填写紧急联系人关系");
				return;
			}
			var data = {
				applyCustomerId:applyCustomerId,
				customerId:customerId,
				cuntryId: countryId,
				travelInfoId: $("#travelInfoId").val(),
				visitPurpose:objectiveResult,
				budget:budget,
				entryTime:entryTime,
				departureTime:departureTime,
				isTo:$("#isTo").val(),
				visitNum:visitNum,
				lastVisitPurpose:latelyObjectiveResult,
				isToOtherCountry:$("#isToOtherCountry").val(),
				isToOtherCountryParameter:isToOtherCountryParameter,
				isFamily:$("#isFamily").val(),
				isFamilyParameter:isFamilyParameter,
				emergencyPersonName:emergencyPersonName,
				inCountry:inCountry,
				emergencyPersonPhone:emergencyPersonPhone,
				applyCustomerRelationship:applyCustomerRelationship
			}
			base.setWait('正在保存，请稍后！');
			base.postData(base.url.addTravelInfo, data, addTravelInfoSuccess);
		});
		function addTravelInfoSuccess(data) {
			mui.toast(data.message);
			if (data.success) {
				setTimeout(function() {
					mui.back();
				}, 1000);
			}
		}	
	</script>
</body>
</html>
